package display 
{
	import controller.Controller;
	import flash.display.MovieClip;
	import flash.display.Sprite;
	import flash.events.Event;
	
	/**
	 * ...
	 * @author Henrik Riise Hansen
	 */
	public class DisplayApplicationBackground extends MovieClip 
	{
		
		private var control:Controller; 
		private var sh:Shell;
		
		// sprites
		
		private var bg:Sprite;
		private var image:Sprite;
		
		public function DisplayApplicationBackground(ctr:Controller,_sh:Shell) 
		{
			sh = _sh;
			
			sh.stage.addEventListener(Event.RESIZE, onStageResized);
			
			build();
			align();
		}
		
		private function build():void
		{
			bg = new Sprite;
			
			bg.graphics.beginFill(0xcccccc, 1);
			bg.graphics.drawRect(0, 0, sh.stage.stageWidth, sh.stage.stageHeight);
			bg.graphics.endFill();
			
			image = new Sprite;
			image.graphics.beginFill(0xffffff, 1);
			image.graphics.drawRect(0, 0, 800, 513);
			image.graphics.endFill();
			
			addChild(bg);
			addChild(image);
		}
		
		private function align():void
		{
			bg.height = sh.stage.stageHeight;
			bg.width = sh.stage.stageWidth;
			
			image.x = ((sh.stage.stageWidth - 200)/ 2) - (image.width/2 ) ;
			image.y = ((sh.stage.stageHeight)/ 2) - (image.height/2);
		}
		
		private function onStageResized(e:Event):void
		{
			align();
		}
		
	}

}